package com.qf.util;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;

/**
 * IntelliJ IDEA -> springboot120622
 * 2019/12/7 8:59
 *
 * @author zmyao
 * 别看，我是渣渣。
 */
//将反射和注解的建立对象的方式进行关联
@Component
public class SpringBean extends AdaptableJobFactory {
    @Autowired
    private AutowireCapableBeanFactory factory;

    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        Object obj = super.createJobInstance(bundle);
        factory.autowireBean(obj);
        return  obj;
    }
}
